import "@stdlib/deploy";

message CounterValue {
    value: Int as uint32;
}

contract Countee with Deployable {

    val: Int as uint32;

    init() {
        self.val = 0;
    }
    
    receive("refund") {
        // step8: 什么都不做,接收toncoin
    }

    // step 6: this contract allows anyone to ask it to increment by 1 (ie. the other contract)
    receive("increment") {
        self.val = self.val + 1;
        // 这里会返回多余未使用的toncoin
        self.reply(CounterValue{value: self.val}.toCell());
    }

    // step 3: this contract replies with its current value to anyone asking (ie. the other contract)
    receive("query") {
        self.reply(CounterValue{value: self.val}.toCell());
    }

    get fun value(): Int {
        return self.val;
    }
}
